using System;
using System.Collections;
using System.Web;
using Sedna.Core.Controls.Support;
using Sedna.Core.Controls.Support.Javascript;

namespace Sedna.Core.Controller
{
	/// <summary>
	/// Base class for nested documents, those, which are loaded into DocumentFrame
	/// </summary>
	public class DocumentFramePage: BasePage
	{
		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);

            IExecutionContext executionContext = Sedna.Core.Controller.ExecutionContext.GetCurrent(ClientID);

            string text = executionContext["frame.text"] as string;
            string textKey = executionContext["frame.textKey"] as string;
//			object state=executionContext["frame.state"];
			
			IConfiguration frameConfiguration= (IConfiguration)SpringContextFactory.GetContext().GetObject("configuration.default.DocumentFrame");
			string title=frameConfiguration.GetLocalizedPostfixLabel(textKey, text);


            JavascriptController.Current.DeclareClass("DocumentFramePage");
            JavascriptController.Current.DeclareObject("page", "DocumentFramePage", title != null ? JavascriptUtil.EncloseWithQuotes(HttpUtility.HtmlAttributeEncode(title)) : "null"/*, state!=null?JavascriptUtil.EncloseWithQuotes(state):"null"*/);
		}
	}
}
